package com.ztf0337.mycurriculumdesign.Utils;

import android.util.Log;

import com.ztf0337.mycurriculumdesign.entity.Order;
import com.ztf0337.mycurriculumdesign.entity.ParkLot;
import com.ztf0337.mycurriculumdesign.entity.ParkingSpace;
import com.ztf0337.mycurriculumdesign.entity.RentedParkingSpace;
import com.ztf0337.mycurriculumdesign.entity.User;

import java.util.List;
import java.util.Objects;

public class CompareClassUtil {

    public static int compareParkLot(List<ParkLot> parkLots, ParkLot parkLot) {
        for (int i = 0; i < parkLots.size(); i++) {
            if (parkLots.get(i).getId().equals(parkLot.getId())) {
                return i;
            }
        }
        return -1;
    }

    public static int compareParkingSpace(List<ParkingSpace> parkingSpaces, ParkingSpace parkingSpace) {
        Log.d("测试","更新id=="+parkingSpace.getId());
        for (int i = 0; i < parkingSpaces.size(); i++) {
            if (parkingSpaces.get(i).getId().equals(parkingSpace.getId())) {
                return i;
            }
        }
        return -1;
    }

    public static int compareOrder(List<Order> orders, Order order) {
        for (int i = 0; i < orders.size(); i++) {
            if (orders.get(i).getId().equals(order.getId())) {
                return i;
            }
        }
        return -1;
    }

    public static int compareRentedParkingSpace(List<RentedParkingSpace> rentedParkingSpaces,
                                                RentedParkingSpace rentedParkingSpace) {
        for (int i = 0; i < rentedParkingSpaces.size(); i++) {
            if (rentedParkingSpaces.get(i).getId().equals(rentedParkingSpace.getId())) {
                return i;
            }
        }
        return -1;
    }

    public static int compareUser(List<User> userList,User user) {
        for (int i = 0; i < userList.size(); i++) {
            if (userList.get(i).getId().equals(user.getId())) {
                return i;
            }
        }
        return -1;
    }

}
